﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using DAL;



public class wechat : IHttpHandler
{
    WeChatDAL WD = new WeChatDAL();
    public void ProcessRequest(HttpContext context)
    {
        string functionname = context.Request.Form["functionname"].ToString();
        switch (functionname)
        {   //添加关键词
            case "jhy_wechat_keywords_add": jhy_wechat_keywords_add(); break;
            //修改关键词
            case "jhy_wechat_keywords_edit": jhy_wechat_keywords_edit(); break;
            //删除关键词
            case "jhy_wechat_keywords_delete": jhy_wechat_keywords_delete(); break;
            //查询关键词
            case "jhy_wechat_keywords_query": jhy_wechat_keywords_query(); break;
            //添加关键词子项
            case "jhy_wechat_keywords_item_add": jhy_wechat_keywords_item_add(); break;
            //修改关键词子项
            case "jhy_wechat_keywords_item_edit": jhy_wechat_keywords_item_edit(); break;
            //删除关键词子项
            case "jhy_wechat_keywords_item_delete": jhy_wechat_keywords_item_delete(); break;
            
            //查询关键词子项
            case "jhy_wechat_keywords_item_query": jhy_wechat_keywords_item_query(); break;
        }
    }

    #region 添加关键词
    public void jhy_wechat_keywords_add()
    {
        string kw_keyword = HttpContext.Current.Request.Form["kw_keyword"].ToString();
        string kw_description = HttpContext.Current.Request.Form["kw_description"].ToString();
        string kw_msgtype = HttpContext.Current.Request.Form["kw_msgtype"].ToString();
        string kw_visable = HttpContext.Current.Request.Form["kw_visable"].ToString();
        
        bool b = WD.jhy_wechat_keywords_add(kw_keyword, kw_description, kw_msgtype, kw_visable);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }

    #endregion
    #region 修改关键词
    public void jhy_wechat_keywords_edit()
    {
        string kw_id = HttpContext.Current.Request.Form["kw_id"].ToString();
        string kw_field = HttpContext.Current.Request.Form["kw_field"].ToString();
        string kw_para = HttpContext.Current.Request.Form["kw_para"].ToString();
        bool b = WD.jhy_wechat_keywords_edit(kw_id, kw_field, kw_para);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 删除关键词
    public void jhy_wechat_keywords_delete()
    {
        string kw_id = HttpContext.Current.Request.Form["kw_id"].ToString();
        bool b = WD.jhy_wechat_keywords_delete(kw_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 查询关键词
    public void jhy_wechat_keywords_query()
    {
        string kw_keyword = HttpContext.Current.Request.Form["kw_keyword"].ToString();
        HttpContext.Current.Response.Write(WD.jhy_wechat_keywords_query(kw_keyword));
    }

    #endregion
    #region 添加关键词子项
    public void jhy_wechat_keywords_item_add()
    {
        string kw_parentid = HttpContext.Current.Request.Form["kw_parentid"].ToString();      
        string kw_news_title = HttpContext.Current.Request.Form["kw_news_title"].ToString();
        string kw_news_description = HttpContext.Current.Request.Form["kw_news_description"].ToString();
        string kw_news_picurl = HttpContext.Current.Request.Form["kw_news_picurl"].ToString();
        string kw_news_url = HttpContext.Current.Request.Form["kw_news_url"].ToString();
        string kw_text_content = HttpContext.Current.Request.Form["kw_text_content"].ToString();
        bool b = WD.jhy_wechat_keywords_item_add(kw_parentid, kw_news_title, kw_news_description, kw_news_picurl, kw_news_url, kw_text_content);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }

    #endregion
    #region 修改关键词子项
    public void jhy_wechat_keywords_item_edit()
    {
        string kw_id = HttpContext.Current.Request.Form["kw_id"].ToString();
        string kw_field = HttpContext.Current.Request.Form["kw_field"].ToString();
        string kw_para = HttpContext.Current.Request.Form["kw_para"].ToString();        
        bool b = WD.jhy_wechat_keywords_item_edit(kw_id, kw_field, kw_para);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }

    }
    #endregion
    #region 删除关键词子项
    public void jhy_wechat_keywords_item_delete()
    {
        string kw_id = HttpContext.Current.Request.Form["kw_id"].ToString();
        bool b = WD.jhy_wechat_keywords_item_delete(kw_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion    
    #region 查询关键词子项
    public void jhy_wechat_keywords_item_query()
    {
        string kw_parentid = HttpContext.Current.Request.Form["kw_parentid"].ToString();
        HttpContext.Current.Response.Write(WD.jhy_wechat_keywords_item_query(kw_parentid));
    }
    #endregion





    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}